</style>
<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">
        <div class=" rc-pannel ">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>


                        <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-sm" id="managefield"><i class="iconfont">&#xe60e;</i> 管理字段</a>

                    </div>
                </div>


            </div>


            <div class="rc-pannel-body layui-form rc-pagepadding">
                <table class="layui-table" id="sort">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                    </colgroup>
                    <thead>
                        <tr>
                            <th>字段</th>
                            <th>字段类型</th>
                            <th>元素控件</th>
                            <th>注册填写?</th>
                            <th>必填?</th>
                            <th>唯一?</th>

                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($fields as $field) {
                        ?>
                            <tr>
                                <td>
                                    <input type="hidden" value="<?php echo $field['id'] ?>" class="sortid" />
                                    <?php echo $field['title'] ?>
                                </td>
                                <td>
                                    <?php
                                    switch ($field['type']) {
                                        case 'string':
                                            echo '字符串';
                                            break;
                                        case 'text':
                                            echo '文本';
                                            break;
                                        case 'integer':
                                            echo '整数';
                                            break;
                                        case 'decimal':
                                            echo '小数';
                                            break;
                                        case 'datetime':
                                            echo '时间';
                                            break;
                                    }
                                    ?>

                                </td>
                                <td>

                                    <?php echo $elements[$field['element']]['title']; ?>

                                    <?php
                                    if ($field['polymorphic'] && $elements[$field['element']]['polymorphic']) {
                                        $polymorphics =  json_decode($elements[$field['element']]['polymorphic'], true);
                                        echo isset($polymorphics[$field['polymorphic']]) ? ' / ' . $polymorphics[$field['polymorphic']] : '';
                                    } ?>


                                    <?php

                                    if ($field['sourcetype'] == 1) {
                                        isset($dicts[$field['sourceval']]) ? $dicts[$field['sourceval']]['title'] : '';
                                    }

                                    if ($field['sourcetype'] == 2) {
                                        $sourceval = explode("\n", str_replace("\r\n", "\n", $field['sourceval']));
                                        echo '<br />';
                                        foreach ($sourceval as $item) {
                                            list($realval, $displayval) = explode('|', $item);
                                            echo '实际值：' . $realval . ' | 显示值：' . $displayval . '<br />';
                                        }
                                    }
                                    ?>

                                </td>
                                <td><i class="layui-icon <?php echo $field['register'] == 1 ? 'layui-icon-ok  rc-text-color-success' : 'layui-icon-close rc-text-color-error' ?> "></i> </td>
                                <td><i class="layui-icon <?php echo $field['require'] == 1 ? 'layui-icon-ok  rc-text-color-success' : 'layui-icon-close rc-text-color-error' ?> ""></i> </td>
                                <td><i class=" layui-icon <?php echo $field['unique'] == 1 ? 'layui-icon-ok  rc-text-color-success' : 'layui-icon-close rc-text-color-error' ?> ""></i> </td>

                            </tr>
                        <?php
                        }
                        ?>



                    </tbody>
                </table>


            </div>
        </div>
    </div>
</div>

<script>
    layui.use(function() {

        var layer = layui.layer;



        $("#managefield").click(function() {
            layer.open({
                type: 2, // page 层类型
                area: ['95%', '800px'],
                title: '字段管理',
                shade: 0.6, // 遮罩透明度
                shadeClose: false, // 点击遮罩区域，关闭弹层
                maxmin: true, // 允许全屏最小化
                anim: 0, // 0-6 的动画形式，-1 不开启
                content: '/admin/cnf/UserModel/regFieldManage'
            });
        });



    });
</script>